<?php

namespace app\admin\model\jdy;

use think\Model;

class Heyue extends Model
{
    // 表名
    protected $name = 'jdy_heyue';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'service_cycle_text',
        'service_hours_text',
        'tax_text',
        'fee_cycle_text',
        'contract_status_text'
    ];
    

    
    public function getServiceCycleList()
    {
        return ['周' => __('周'),'月' => __('月'),'季' => __('季')];
    }     

    public function getServiceHoursList()
    {
        return ['0' => "AM：09:30~PM12:30 或 PM13:30~PM17:00", '1' => "AM：09:30~PM12:30 及 PM13:30~PM17:00"];
    }     

    public function getTaxList()
    {
        return ['不含稅' => __('不含稅'),'含稅' => __('含稅')];
    }     

    public function getFeeCycleList()
    {
        return ['月繳' => __('月繳'),'季繳' => __('季繳'),'半年繳' => __('半年繳'),'年繳' => __('年繳')];
    }     

    public function getContractStatusList()
    {
        return ['生效' => __('生效'),'中止' => __('中止')];
    }     


    public function getServiceCycleTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['service_cycle']) ? $data['service_cycle'] : '');
        $list = $this->getServiceCycleList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getServiceHoursTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['service_hours']) ? $data['service_hours'] : '');
        $list = $this->getServiceHoursList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getTaxTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['tax']) ? $data['tax'] : '');
        $list = $this->getTaxList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getFeeCycleTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['fee_cycle']) ? $data['fee_cycle'] : '');
        $list = $this->getFeeCycleList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getContractStatusTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['contract_status']) ? $data['contract_status'] : '');
        $list = $this->getContractStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function anchang()
    {
        return $this->belongsTo('Anchang', 'anchang_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
